//
//  SecondViewController.m
//  DataBindExample
//
//  Created by Super on 2019/12/20.
//  Copyright © 2019 Super. All rights reserved.
//

#import "SecondViewController.h"

@interface SecondViewController ()

@property (weak, nonatomic) IBOutlet UILabel *firstLabel;
@property (nonatomic, assign) NSInteger colorTag;

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.colorTag = 1;
    
    [self bindModel:self.model modelKey:@"num" viewInfo:self.firstLabel.textInfo block:^{
        NSLog(@"数据更新啦1");
    }];
    
    [self bindModel:self.model modelKey:@"color" viewInfo:self.firstLabel.textColorInfo block:^{
        NSLog(@"数据更新啦2");
    }];
}

- (IBAction)addNumBindModel:(id)sender {
    self.model.num++;
}

- (IBAction)minusNumBindModel:(id)sender {
    self.model.num--;
}

- (IBAction)changeColorBindModel:(id)sender {
    self.colorTag = self.colorTag * -1;
    if (self.colorTag > 0) {
        self.model.color = [UIColor orangeColor];
    } else {
        self.model.color = [UIColor grayColor];
    }
}

@end
